<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Caffe: include/caffe/layers/base_conv_layer.hpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">Caffe
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_d44c64559bbebec7f509842c48db8b23.html">include</a></li><li class="navelem"><a class="el" href="dir_4b7f3da7c7b4301d805dae0326fb91b7.html">caffe</a></li><li class="navelem"><a class="el" href="dir_b9606a76d4acbf8f90a06a4a51ec8b9e.html">layers</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">base_conv_layer.hpp</div>  </div>
</div><!--header-->
<div class="contents">
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="preprocessor">#ifndef CAFFE_BASE_CONVOLUTION_LAYER_HPP_</span></div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;<span class="preprocessor">#define CAFFE_BASE_CONVOLUTION_LAYER_HPP_</span></div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;</div><div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="preprocessor">#include &lt;vector&gt;</span></div><div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;</div><div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;<span class="preprocessor">#include &quot;caffe/blob.hpp&quot;</span></div><div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;<span class="preprocessor">#include &quot;caffe/layer.hpp&quot;</span></div><div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;<span class="preprocessor">#include &quot;caffe/proto/caffe.pb.h&quot;</span></div><div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;<span class="preprocessor">#include &quot;caffe/util/im2col.hpp&quot;</span></div><div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;</div><div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;<span class="keyword">namespace </span><a class="code" href="namespacecaffe.html">caffe</a> {</div><div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;</div><div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;<span class="keyword">template</span> &lt;<span class="keyword">typename</span> Dtype&gt;</div><div class="line"><a name="l00018"></a><span class="lineno"><a class="line" href="classcaffe_1_1BaseConvolutionLayer.html">   18</a></span>&#160;<span class="keyword">class </span><a class="code" href="classcaffe_1_1BaseConvolutionLayer.html">BaseConvolutionLayer</a> : <span class="keyword">public</span> <a class="code" href="classcaffe_1_1Layer.html">Layer</a>&lt;Dtype&gt; {</div><div class="line"><a name="l00019"></a><span class="lineno">   19</span>&#160; <span class="keyword">public</span>:</div><div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160;  <span class="keyword">explicit</span> <a class="code" href="classcaffe_1_1BaseConvolutionLayer.html">BaseConvolutionLayer</a>(<span class="keyword">const</span> LayerParameter&amp; param)</div><div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;      : <a class="code" href="classcaffe_1_1Layer.html">Layer&lt;Dtype&gt;</a>(param) {}</div><div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;  <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classcaffe_1_1BaseConvolutionLayer.html#a422e1ef9e6c8b4574f7677bb125e234a">LayerSetUp</a>(<span class="keyword">const</span> vector&lt;<a class="code" href="classcaffe_1_1Blob.html">Blob&lt;Dtype&gt;</a>*&gt;&amp; bottom,</div><div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160;      <span class="keyword">const</span> vector&lt;<a class="code" href="classcaffe_1_1Blob.html">Blob&lt;Dtype&gt;</a>*&gt;&amp; top);</div><div class="line"><a name="l00024"></a><span class="lineno">   24</span>&#160;  <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classcaffe_1_1BaseConvolutionLayer.html#aa215338f200c832081f2719a54bc5256">Reshape</a>(<span class="keyword">const</span> vector&lt;<a class="code" href="classcaffe_1_1Blob.html">Blob&lt;Dtype&gt;</a>*&gt;&amp; bottom,</div><div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;      <span class="keyword">const</span> vector&lt;<a class="code" href="classcaffe_1_1Blob.html">Blob&lt;Dtype&gt;</a>*&gt;&amp; top);</div><div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160;</div><div class="line"><a name="l00027"></a><span class="lineno"><a class="line" href="classcaffe_1_1BaseConvolutionLayer.html#aa3d861ed15f6e41c6257d6a10defa7eb">   27</a></span>&#160;  <span class="keyword">virtual</span> <span class="keyword">inline</span> <span class="keywordtype">int</span> <a class="code" href="classcaffe_1_1BaseConvolutionLayer.html#aa3d861ed15f6e41c6257d6a10defa7eb">MinBottomBlobs</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> 1; }</div><div class="line"><a name="l00028"></a><span class="lineno"><a class="line" href="classcaffe_1_1BaseConvolutionLayer.html#ae4092cf1b48e18e5d82cd714ae6e8547">   28</a></span>&#160;  <span class="keyword">virtual</span> <span class="keyword">inline</span> <span class="keywordtype">int</span> <a class="code" href="classcaffe_1_1BaseConvolutionLayer.html#ae4092cf1b48e18e5d82cd714ae6e8547">MinTopBlobs</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> 1; }</div><div class="line"><a name="l00029"></a><span class="lineno"><a class="line" href="classcaffe_1_1BaseConvolutionLayer.html#ad8e839460bf52abe3df2008b99a1810d">   29</a></span>&#160;  <span class="keyword">virtual</span> <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="classcaffe_1_1BaseConvolutionLayer.html#ad8e839460bf52abe3df2008b99a1810d">EqualNumBottomTopBlobs</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <span class="keyword">true</span>; }</div><div class="line"><a name="l00030"></a><span class="lineno">   30</span>&#160;</div><div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160; <span class="keyword">protected</span>:</div><div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;  <span class="comment">// Helper functions that abstract away the column buffer and gemm arguments.</span></div><div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;  <span class="comment">// The last argument in forward_cpu_gemm is so that we can skip the im2col if</span></div><div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;  <span class="comment">// we just called weight_cpu_gemm with the same input.</span></div><div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;  <span class="keywordtype">void</span> forward_cpu_gemm(<span class="keyword">const</span> Dtype* input, <span class="keyword">const</span> Dtype* weights,</div><div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;      Dtype* output, <span class="keywordtype">bool</span> skip_im2col = <span class="keyword">false</span>);</div><div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160;  <span class="keywordtype">void</span> forward_cpu_bias(Dtype* output, <span class="keyword">const</span> Dtype* bias);</div><div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;  <span class="keywordtype">void</span> backward_cpu_gemm(<span class="keyword">const</span> Dtype* input, <span class="keyword">const</span> Dtype* weights,</div><div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;      Dtype* output);</div><div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;  <span class="keywordtype">void</span> weight_cpu_gemm(<span class="keyword">const</span> Dtype* input, <span class="keyword">const</span> Dtype* output, Dtype*</div><div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;      weights);</div><div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160;  <span class="keywordtype">void</span> backward_cpu_bias(Dtype* bias, <span class="keyword">const</span> Dtype* input);</div><div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;</div><div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;<span class="preprocessor">#ifndef CPU_ONLY</span></div><div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;  <span class="keywordtype">void</span> forward_gpu_gemm(<span class="keyword">const</span> Dtype* col_input, <span class="keyword">const</span> Dtype* weights,</div><div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;      Dtype* output, <span class="keywordtype">bool</span> skip_im2col = <span class="keyword">false</span>);</div><div class="line"><a name="l00047"></a><span class="lineno">   47</span>&#160;  <span class="keywordtype">void</span> forward_gpu_bias(Dtype* output, <span class="keyword">const</span> Dtype* bias);</div><div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160;  <span class="keywordtype">void</span> backward_gpu_gemm(<span class="keyword">const</span> Dtype* input, <span class="keyword">const</span> Dtype* weights,</div><div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160;      Dtype* col_output);</div><div class="line"><a name="l00050"></a><span class="lineno">   50</span>&#160;  <span class="keywordtype">void</span> weight_gpu_gemm(<span class="keyword">const</span> Dtype* col_input, <span class="keyword">const</span> Dtype* output, Dtype*</div><div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160;      weights);</div><div class="line"><a name="l00052"></a><span class="lineno">   52</span>&#160;  <span class="keywordtype">void</span> backward_gpu_bias(Dtype* bias, <span class="keyword">const</span> Dtype* input);</div><div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160;<span class="preprocessor">#endif</span></div><div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;</div><div class="line"><a name="l00056"></a><span class="lineno"><a class="line" href="classcaffe_1_1BaseConvolutionLayer.html#a6324d4ab918a7b09399aa85a8a03737d">   56</a></span>&#160;  <span class="keyword">inline</span> <span class="keywordtype">int</span> <a class="code" href="classcaffe_1_1BaseConvolutionLayer.html#a6324d4ab918a7b09399aa85a8a03737d">input_shape</a>(<span class="keywordtype">int</span> i) {</div><div class="line"><a name="l00057"></a><span class="lineno">   57</span>&#160;    <span class="keywordflow">return</span> (*bottom_shape_)[channel_axis_ + i];</div><div class="line"><a name="l00058"></a><span class="lineno">   58</span>&#160;  }</div><div class="line"><a name="l00059"></a><span class="lineno">   59</span>&#160;  <span class="comment">// reverse_dimensions should return true iff we are implementing deconv, so</span></div><div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160;  <span class="comment">// that conv helpers know which dimensions are which.</span></div><div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;  <span class="keyword">virtual</span> <span class="keywordtype">bool</span> reverse_dimensions() = 0;</div><div class="line"><a name="l00062"></a><span class="lineno">   62</span>&#160;  <span class="comment">// Compute height_out_ and width_out_ from other parameters.</span></div><div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160;  <span class="keyword">virtual</span> <span class="keywordtype">void</span> compute_output_shape() = 0;</div><div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160;</div><div class="line"><a name="l00066"></a><span class="lineno"><a class="line" href="classcaffe_1_1BaseConvolutionLayer.html#a0a2f112eec8a7cbd13888185d4fb36b0">   66</a></span>&#160;  <a class="code" href="classcaffe_1_1Blob.html">Blob&lt;int&gt;</a> <a class="code" href="classcaffe_1_1BaseConvolutionLayer.html#a0a2f112eec8a7cbd13888185d4fb36b0">kernel_shape_</a>;</div><div class="line"><a name="l00068"></a><span class="lineno"><a class="line" href="classcaffe_1_1BaseConvolutionLayer.html#af638d3d8e67c33443cb11cb000368e73">   68</a></span>&#160;  <a class="code" href="classcaffe_1_1Blob.html">Blob&lt;int&gt;</a> <a class="code" href="classcaffe_1_1BaseConvolutionLayer.html#af638d3d8e67c33443cb11cb000368e73">stride_</a>;</div><div class="line"><a name="l00070"></a><span class="lineno"><a class="line" href="classcaffe_1_1BaseConvolutionLayer.html#a897ead2823e9031863e2151e71229e35">   70</a></span>&#160;  <a class="code" href="classcaffe_1_1Blob.html">Blob&lt;int&gt;</a> <a class="code" href="classcaffe_1_1BaseConvolutionLayer.html#a897ead2823e9031863e2151e71229e35">pad_</a>;</div><div class="line"><a name="l00072"></a><span class="lineno"><a class="line" href="classcaffe_1_1BaseConvolutionLayer.html#a91f929109b5c05ba6086d4c2a741ad4a">   72</a></span>&#160;  <a class="code" href="classcaffe_1_1Blob.html">Blob&lt;int&gt;</a> <a class="code" href="classcaffe_1_1BaseConvolutionLayer.html#a91f929109b5c05ba6086d4c2a741ad4a">dilation_</a>;</div><div class="line"><a name="l00074"></a><span class="lineno"><a class="line" href="classcaffe_1_1BaseConvolutionLayer.html#a63756d6ef00f6491939e539094c21397">   74</a></span>&#160;  <a class="code" href="classcaffe_1_1Blob.html">Blob&lt;int&gt;</a> <a class="code" href="classcaffe_1_1BaseConvolutionLayer.html#a63756d6ef00f6491939e539094c21397">conv_input_shape_</a>;</div><div class="line"><a name="l00076"></a><span class="lineno"><a class="line" href="classcaffe_1_1BaseConvolutionLayer.html#a9dd3f4ea6e17fe155efe537c120a3de4">   76</a></span>&#160;  vector&lt;int&gt; <a class="code" href="classcaffe_1_1BaseConvolutionLayer.html#a9dd3f4ea6e17fe155efe537c120a3de4">col_buffer_shape_</a>;</div><div class="line"><a name="l00078"></a><span class="lineno"><a class="line" href="classcaffe_1_1BaseConvolutionLayer.html#af0892b61454ba086c4c74b78d910bf31">   78</a></span>&#160;  vector&lt;int&gt; <a class="code" href="classcaffe_1_1BaseConvolutionLayer.html#af0892b61454ba086c4c74b78d910bf31">output_shape_</a>;</div><div class="line"><a name="l00079"></a><span class="lineno">   79</span>&#160;  <span class="keyword">const</span> vector&lt;int&gt;* bottom_shape_;</div><div class="line"><a name="l00080"></a><span class="lineno">   80</span>&#160;</div><div class="line"><a name="l00081"></a><span class="lineno">   81</span>&#160;  <span class="keywordtype">int</span> num_spatial_axes_;</div><div class="line"><a name="l00082"></a><span class="lineno">   82</span>&#160;  <span class="keywordtype">int</span> bottom_dim_;</div><div class="line"><a name="l00083"></a><span class="lineno">   83</span>&#160;  <span class="keywordtype">int</span> top_dim_;</div><div class="line"><a name="l00084"></a><span class="lineno">   84</span>&#160;</div><div class="line"><a name="l00085"></a><span class="lineno">   85</span>&#160;  <span class="keywordtype">int</span> channel_axis_;</div><div class="line"><a name="l00086"></a><span class="lineno">   86</span>&#160;  <span class="keywordtype">int</span> num_;</div><div class="line"><a name="l00087"></a><span class="lineno">   87</span>&#160;  <span class="keywordtype">int</span> channels_;</div><div class="line"><a name="l00088"></a><span class="lineno">   88</span>&#160;  <span class="keywordtype">int</span> group_;</div><div class="line"><a name="l00089"></a><span class="lineno">   89</span>&#160;  <span class="keywordtype">int</span> out_spatial_dim_;</div><div class="line"><a name="l00090"></a><span class="lineno">   90</span>&#160;  <span class="keywordtype">int</span> weight_offset_;</div><div class="line"><a name="l00091"></a><span class="lineno">   91</span>&#160;  <span class="keywordtype">int</span> num_output_;</div><div class="line"><a name="l00092"></a><span class="lineno">   92</span>&#160;  <span class="keywordtype">bool</span> bias_term_;</div><div class="line"><a name="l00093"></a><span class="lineno">   93</span>&#160;  <span class="keywordtype">bool</span> is_1x1_;</div><div class="line"><a name="l00094"></a><span class="lineno">   94</span>&#160;  <span class="keywordtype">bool</span> force_nd_im2col_;</div><div class="line"><a name="l00095"></a><span class="lineno">   95</span>&#160;</div><div class="line"><a name="l00096"></a><span class="lineno">   96</span>&#160; <span class="keyword">private</span>:</div><div class="line"><a name="l00097"></a><span class="lineno">   97</span>&#160;  <span class="comment">// wrap im2col/col2im so we don&#39;t have to remember the (long) argument lists</span></div><div class="line"><a name="l00098"></a><span class="lineno">   98</span>&#160;  <span class="keyword">inline</span> <span class="keywordtype">void</span> conv_im2col_cpu(<span class="keyword">const</span> Dtype* data, Dtype* col_buff) {</div><div class="line"><a name="l00099"></a><span class="lineno">   99</span>&#160;    <span class="keywordflow">if</span> (!force_nd_im2col_ &amp;&amp; num_spatial_axes_ == 2) {</div><div class="line"><a name="l00100"></a><span class="lineno">  100</span>&#160;      im2col_cpu(data, conv_in_channels_,</div><div class="line"><a name="l00101"></a><span class="lineno">  101</span>&#160;          conv_input_shape_.cpu_data()[1], conv_input_shape_.cpu_data()[2],</div><div class="line"><a name="l00102"></a><span class="lineno">  102</span>&#160;          kernel_shape_.cpu_data()[0], kernel_shape_.cpu_data()[1],</div><div class="line"><a name="l00103"></a><span class="lineno">  103</span>&#160;          pad_.cpu_data()[0], pad_.cpu_data()[1],</div><div class="line"><a name="l00104"></a><span class="lineno">  104</span>&#160;          stride_.cpu_data()[0], stride_.cpu_data()[1],</div><div class="line"><a name="l00105"></a><span class="lineno">  105</span>&#160;          dilation_.cpu_data()[0], dilation_.cpu_data()[1], col_buff);</div><div class="line"><a name="l00106"></a><span class="lineno">  106</span>&#160;    } <span class="keywordflow">else</span> {</div><div class="line"><a name="l00107"></a><span class="lineno">  107</span>&#160;      im2col_nd_cpu(data, num_spatial_axes_, conv_input_shape_.cpu_data(),</div><div class="line"><a name="l00108"></a><span class="lineno">  108</span>&#160;          col_buffer_shape_.data(), kernel_shape_.cpu_data(),</div><div class="line"><a name="l00109"></a><span class="lineno">  109</span>&#160;          pad_.cpu_data(), stride_.cpu_data(), dilation_.cpu_data(), col_buff);</div><div class="line"><a name="l00110"></a><span class="lineno">  110</span>&#160;    }</div><div class="line"><a name="l00111"></a><span class="lineno">  111</span>&#160;  }</div><div class="line"><a name="l00112"></a><span class="lineno">  112</span>&#160;  <span class="keyword">inline</span> <span class="keywordtype">void</span> conv_col2im_cpu(<span class="keyword">const</span> Dtype* col_buff, Dtype* data) {</div><div class="line"><a name="l00113"></a><span class="lineno">  113</span>&#160;    <span class="keywordflow">if</span> (!force_nd_im2col_ &amp;&amp; num_spatial_axes_ == 2) {</div><div class="line"><a name="l00114"></a><span class="lineno">  114</span>&#160;      col2im_cpu(col_buff, conv_in_channels_,</div><div class="line"><a name="l00115"></a><span class="lineno">  115</span>&#160;          conv_input_shape_.cpu_data()[1], conv_input_shape_.cpu_data()[2],</div><div class="line"><a name="l00116"></a><span class="lineno">  116</span>&#160;          kernel_shape_.cpu_data()[0], kernel_shape_.cpu_data()[1],</div><div class="line"><a name="l00117"></a><span class="lineno">  117</span>&#160;          pad_.cpu_data()[0], pad_.cpu_data()[1],</div><div class="line"><a name="l00118"></a><span class="lineno">  118</span>&#160;          stride_.cpu_data()[0], stride_.cpu_data()[1],</div><div class="line"><a name="l00119"></a><span class="lineno">  119</span>&#160;          dilation_.cpu_data()[0], dilation_.cpu_data()[1], data);</div><div class="line"><a name="l00120"></a><span class="lineno">  120</span>&#160;    } <span class="keywordflow">else</span> {</div><div class="line"><a name="l00121"></a><span class="lineno">  121</span>&#160;      col2im_nd_cpu(col_buff, num_spatial_axes_, conv_input_shape_.cpu_data(),</div><div class="line"><a name="l00122"></a><span class="lineno">  122</span>&#160;          col_buffer_shape_.data(), kernel_shape_.cpu_data(),</div><div class="line"><a name="l00123"></a><span class="lineno">  123</span>&#160;          pad_.cpu_data(), stride_.cpu_data(), dilation_.cpu_data(), data);</div><div class="line"><a name="l00124"></a><span class="lineno">  124</span>&#160;    }</div><div class="line"><a name="l00125"></a><span class="lineno">  125</span>&#160;  }</div><div class="line"><a name="l00126"></a><span class="lineno">  126</span>&#160;<span class="preprocessor">#ifndef CPU_ONLY</span></div><div class="line"><a name="l00127"></a><span class="lineno">  127</span>&#160;  <span class="keyword">inline</span> <span class="keywordtype">void</span> conv_im2col_gpu(<span class="keyword">const</span> Dtype* data, Dtype* col_buff) {</div><div class="line"><a name="l00128"></a><span class="lineno">  128</span>&#160;    <span class="keywordflow">if</span> (!force_nd_im2col_ &amp;&amp; num_spatial_axes_ == 2) {</div><div class="line"><a name="l00129"></a><span class="lineno">  129</span>&#160;      im2col_gpu(data, conv_in_channels_,</div><div class="line"><a name="l00130"></a><span class="lineno">  130</span>&#160;          conv_input_shape_.cpu_data()[1], conv_input_shape_.cpu_data()[2],</div><div class="line"><a name="l00131"></a><span class="lineno">  131</span>&#160;          kernel_shape_.cpu_data()[0], kernel_shape_.cpu_data()[1],</div><div class="line"><a name="l00132"></a><span class="lineno">  132</span>&#160;          pad_.cpu_data()[0], pad_.cpu_data()[1],</div><div class="line"><a name="l00133"></a><span class="lineno">  133</span>&#160;          stride_.cpu_data()[0], stride_.cpu_data()[1],</div><div class="line"><a name="l00134"></a><span class="lineno">  134</span>&#160;          dilation_.cpu_data()[0], dilation_.cpu_data()[1], col_buff);</div><div class="line"><a name="l00135"></a><span class="lineno">  135</span>&#160;    } <span class="keywordflow">else</span> {</div><div class="line"><a name="l00136"></a><span class="lineno">  136</span>&#160;      im2col_nd_gpu(data, num_spatial_axes_, num_kernels_im2col_,</div><div class="line"><a name="l00137"></a><span class="lineno">  137</span>&#160;          conv_input_shape_.gpu_data(), col_buffer_.gpu_shape(),</div><div class="line"><a name="l00138"></a><span class="lineno">  138</span>&#160;          kernel_shape_.gpu_data(), pad_.gpu_data(),</div><div class="line"><a name="l00139"></a><span class="lineno">  139</span>&#160;          stride_.gpu_data(), dilation_.gpu_data(), col_buff);</div><div class="line"><a name="l00140"></a><span class="lineno">  140</span>&#160;    }</div><div class="line"><a name="l00141"></a><span class="lineno">  141</span>&#160;  }</div><div class="line"><a name="l00142"></a><span class="lineno">  142</span>&#160;  <span class="keyword">inline</span> <span class="keywordtype">void</span> conv_col2im_gpu(<span class="keyword">const</span> Dtype* col_buff, Dtype* data) {</div><div class="line"><a name="l00143"></a><span class="lineno">  143</span>&#160;    <span class="keywordflow">if</span> (!force_nd_im2col_ &amp;&amp; num_spatial_axes_ == 2) {</div><div class="line"><a name="l00144"></a><span class="lineno">  144</span>&#160;      col2im_gpu(col_buff, conv_in_channels_,</div><div class="line"><a name="l00145"></a><span class="lineno">  145</span>&#160;          conv_input_shape_.cpu_data()[1], conv_input_shape_.cpu_data()[2],</div><div class="line"><a name="l00146"></a><span class="lineno">  146</span>&#160;          kernel_shape_.cpu_data()[0], kernel_shape_.cpu_data()[1],</div><div class="line"><a name="l00147"></a><span class="lineno">  147</span>&#160;          pad_.cpu_data()[0], pad_.cpu_data()[1],</div><div class="line"><a name="l00148"></a><span class="lineno">  148</span>&#160;          stride_.cpu_data()[0], stride_.cpu_data()[1],</div><div class="line"><a name="l00149"></a><span class="lineno">  149</span>&#160;          dilation_.cpu_data()[0], dilation_.cpu_data()[1], data);</div><div class="line"><a name="l00150"></a><span class="lineno">  150</span>&#160;    } <span class="keywordflow">else</span> {</div><div class="line"><a name="l00151"></a><span class="lineno">  151</span>&#160;      col2im_nd_gpu(col_buff, num_spatial_axes_, num_kernels_col2im_,</div><div class="line"><a name="l00152"></a><span class="lineno">  152</span>&#160;          conv_input_shape_.gpu_data(), col_buffer_.gpu_shape(),</div><div class="line"><a name="l00153"></a><span class="lineno">  153</span>&#160;          kernel_shape_.gpu_data(), pad_.gpu_data(), stride_.gpu_data(),</div><div class="line"><a name="l00154"></a><span class="lineno">  154</span>&#160;          dilation_.gpu_data(), data);</div><div class="line"><a name="l00155"></a><span class="lineno">  155</span>&#160;    }</div><div class="line"><a name="l00156"></a><span class="lineno">  156</span>&#160;  }</div><div class="line"><a name="l00157"></a><span class="lineno">  157</span>&#160;<span class="preprocessor">#endif</span></div><div class="line"><a name="l00158"></a><span class="lineno">  158</span>&#160;</div><div class="line"><a name="l00159"></a><span class="lineno">  159</span>&#160;  <span class="keywordtype">int</span> num_kernels_im2col_;</div><div class="line"><a name="l00160"></a><span class="lineno">  160</span>&#160;  <span class="keywordtype">int</span> num_kernels_col2im_;</div><div class="line"><a name="l00161"></a><span class="lineno">  161</span>&#160;  <span class="keywordtype">int</span> conv_out_channels_;</div><div class="line"><a name="l00162"></a><span class="lineno">  162</span>&#160;  <span class="keywordtype">int</span> conv_in_channels_;</div><div class="line"><a name="l00163"></a><span class="lineno">  163</span>&#160;  <span class="keywordtype">int</span> conv_out_spatial_dim_;</div><div class="line"><a name="l00164"></a><span class="lineno">  164</span>&#160;  <span class="keywordtype">int</span> kernel_dim_;</div><div class="line"><a name="l00165"></a><span class="lineno">  165</span>&#160;  <span class="keywordtype">int</span> col_offset_;</div><div class="line"><a name="l00166"></a><span class="lineno">  166</span>&#160;  <span class="keywordtype">int</span> output_offset_;</div><div class="line"><a name="l00167"></a><span class="lineno">  167</span>&#160;</div><div class="line"><a name="l00168"></a><span class="lineno">  168</span>&#160;  <a class="code" href="classcaffe_1_1Blob.html">Blob&lt;Dtype&gt;</a> col_buffer_;</div><div class="line"><a name="l00169"></a><span class="lineno">  169</span>&#160;  <a class="code" href="classcaffe_1_1Blob.html">Blob&lt;Dtype&gt;</a> bias_multiplier_;</div><div class="line"><a name="l00170"></a><span class="lineno">  170</span>&#160;};</div><div class="line"><a name="l00171"></a><span class="lineno">  171</span>&#160;</div><div class="line"><a name="l00172"></a><span class="lineno">  172</span>&#160;}  <span class="comment">// namespace caffe</span></div><div class="line"><a name="l00173"></a><span class="lineno">  173</span>&#160;</div><div class="line"><a name="l00174"></a><span class="lineno">  174</span>&#160;<span class="preprocessor">#endif  // CAFFE_BASE_CONVOLUTION_LAYER_HPP_</span></div><div class="ttc" id="classcaffe_1_1BaseConvolutionLayer_html_a0a2f112eec8a7cbd13888185d4fb36b0"><div class="ttname"><a href="classcaffe_1_1BaseConvolutionLayer.html#a0a2f112eec8a7cbd13888185d4fb36b0">caffe::BaseConvolutionLayer::kernel_shape_</a></div><div class="ttdeci">Blob&lt; int &gt; kernel_shape_</div><div class="ttdoc">The spatial dimensions of a filter kernel. </div><div class="ttdef"><b>Definition:</b> base_conv_layer.hpp:66</div></div>
<div class="ttc" id="classcaffe_1_1Layer_html"><div class="ttname"><a href="classcaffe_1_1Layer.html">caffe::Layer</a></div><div class="ttdoc">An interface for the units of computation which can be composed into a Net. </div><div class="ttdef"><b>Definition:</b> layer.hpp:33</div></div>
<div class="ttc" id="namespacecaffe_html"><div class="ttname"><a href="namespacecaffe.html">caffe</a></div><div class="ttdoc">A layer factory that allows one to register layers. During runtime, registered layers can be called b...</div><div class="ttdef"><b>Definition:</b> blob.hpp:14</div></div>
<div class="ttc" id="classcaffe_1_1BaseConvolutionLayer_html_a6324d4ab918a7b09399aa85a8a03737d"><div class="ttname"><a href="classcaffe_1_1BaseConvolutionLayer.html#a6324d4ab918a7b09399aa85a8a03737d">caffe::BaseConvolutionLayer::input_shape</a></div><div class="ttdeci">int input_shape(int i)</div><div class="ttdoc">The spatial dimensions of the input. </div><div class="ttdef"><b>Definition:</b> base_conv_layer.hpp:56</div></div>
<div class="ttc" id="classcaffe_1_1BaseConvolutionLayer_html_a422e1ef9e6c8b4574f7677bb125e234a"><div class="ttname"><a href="classcaffe_1_1BaseConvolutionLayer.html#a422e1ef9e6c8b4574f7677bb125e234a">caffe::BaseConvolutionLayer::LayerSetUp</a></div><div class="ttdeci">virtual void LayerSetUp(const vector&lt; Blob&lt; Dtype &gt; *&gt; &amp;bottom, const vector&lt; Blob&lt; Dtype &gt; *&gt; &amp;top)</div><div class="ttdoc">Does layer-specific setup: your layer should implement this function as well as Reshape. </div><div class="ttdef"><b>Definition:</b> base_conv_layer.cpp:12</div></div>
<div class="ttc" id="classcaffe_1_1BaseConvolutionLayer_html"><div class="ttname"><a href="classcaffe_1_1BaseConvolutionLayer.html">caffe::BaseConvolutionLayer</a></div><div class="ttdoc">Abstract base class that factors out the BLAS code common to ConvolutionLayer and DeconvolutionLayer...</div><div class="ttdef"><b>Definition:</b> base_conv_layer.hpp:18</div></div>
<div class="ttc" id="classcaffe_1_1BaseConvolutionLayer_html_ad8e839460bf52abe3df2008b99a1810d"><div class="ttname"><a href="classcaffe_1_1BaseConvolutionLayer.html#ad8e839460bf52abe3df2008b99a1810d">caffe::BaseConvolutionLayer::EqualNumBottomTopBlobs</a></div><div class="ttdeci">virtual bool EqualNumBottomTopBlobs() const</div><div class="ttdoc">Returns true if the layer requires an equal number of bottom and top blobs. </div><div class="ttdef"><b>Definition:</b> base_conv_layer.hpp:29</div></div>
<div class="ttc" id="classcaffe_1_1BaseConvolutionLayer_html_aa3d861ed15f6e41c6257d6a10defa7eb"><div class="ttname"><a href="classcaffe_1_1BaseConvolutionLayer.html#aa3d861ed15f6e41c6257d6a10defa7eb">caffe::BaseConvolutionLayer::MinBottomBlobs</a></div><div class="ttdeci">virtual int MinBottomBlobs() const</div><div class="ttdoc">Returns the minimum number of bottom blobs required by the layer, or -1 if no minimum number is requi...</div><div class="ttdef"><b>Definition:</b> base_conv_layer.hpp:27</div></div>
<div class="ttc" id="classcaffe_1_1BaseConvolutionLayer_html_a897ead2823e9031863e2151e71229e35"><div class="ttname"><a href="classcaffe_1_1BaseConvolutionLayer.html#a897ead2823e9031863e2151e71229e35">caffe::BaseConvolutionLayer::pad_</a></div><div class="ttdeci">Blob&lt; int &gt; pad_</div><div class="ttdoc">The spatial dimensions of the padding. </div><div class="ttdef"><b>Definition:</b> base_conv_layer.hpp:70</div></div>
<div class="ttc" id="classcaffe_1_1BaseConvolutionLayer_html_ae4092cf1b48e18e5d82cd714ae6e8547"><div class="ttname"><a href="classcaffe_1_1BaseConvolutionLayer.html#ae4092cf1b48e18e5d82cd714ae6e8547">caffe::BaseConvolutionLayer::MinTopBlobs</a></div><div class="ttdeci">virtual int MinTopBlobs() const</div><div class="ttdoc">Returns the minimum number of top blobs required by the layer, or -1 if no minimum number is required...</div><div class="ttdef"><b>Definition:</b> base_conv_layer.hpp:28</div></div>
<div class="ttc" id="classcaffe_1_1BaseConvolutionLayer_html_a9dd3f4ea6e17fe155efe537c120a3de4"><div class="ttname"><a href="classcaffe_1_1BaseConvolutionLayer.html#a9dd3f4ea6e17fe155efe537c120a3de4">caffe::BaseConvolutionLayer::col_buffer_shape_</a></div><div class="ttdeci">vector&lt; int &gt; col_buffer_shape_</div><div class="ttdoc">The spatial dimensions of the col_buffer. </div><div class="ttdef"><b>Definition:</b> base_conv_layer.hpp:76</div></div>
<div class="ttc" id="classcaffe_1_1BaseConvolutionLayer_html_af0892b61454ba086c4c74b78d910bf31"><div class="ttname"><a href="classcaffe_1_1BaseConvolutionLayer.html#af0892b61454ba086c4c74b78d910bf31">caffe::BaseConvolutionLayer::output_shape_</a></div><div class="ttdeci">vector&lt; int &gt; output_shape_</div><div class="ttdoc">The spatial dimensions of the output. </div><div class="ttdef"><b>Definition:</b> base_conv_layer.hpp:78</div></div>
<div class="ttc" id="classcaffe_1_1BaseConvolutionLayer_html_aa215338f200c832081f2719a54bc5256"><div class="ttname"><a href="classcaffe_1_1BaseConvolutionLayer.html#aa215338f200c832081f2719a54bc5256">caffe::BaseConvolutionLayer::Reshape</a></div><div class="ttdeci">virtual void Reshape(const vector&lt; Blob&lt; Dtype &gt; *&gt; &amp;bottom, const vector&lt; Blob&lt; Dtype &gt; *&gt; &amp;top)</div><div class="ttdoc">Adjust the shapes of top blobs and internal buffers to accommodate the shapes of the bottom blobs...</div><div class="ttdef"><b>Definition:</b> base_conv_layer.cpp:185</div></div>
<div class="ttc" id="classcaffe_1_1BaseConvolutionLayer_html_a63756d6ef00f6491939e539094c21397"><div class="ttname"><a href="classcaffe_1_1BaseConvolutionLayer.html#a63756d6ef00f6491939e539094c21397">caffe::BaseConvolutionLayer::conv_input_shape_</a></div><div class="ttdeci">Blob&lt; int &gt; conv_input_shape_</div><div class="ttdoc">The spatial dimensions of the convolution input. </div><div class="ttdef"><b>Definition:</b> base_conv_layer.hpp:74</div></div>
<div class="ttc" id="classcaffe_1_1BaseConvolutionLayer_html_af638d3d8e67c33443cb11cb000368e73"><div class="ttname"><a href="classcaffe_1_1BaseConvolutionLayer.html#af638d3d8e67c33443cb11cb000368e73">caffe::BaseConvolutionLayer::stride_</a></div><div class="ttdeci">Blob&lt; int &gt; stride_</div><div class="ttdoc">The spatial dimensions of the stride. </div><div class="ttdef"><b>Definition:</b> base_conv_layer.hpp:68</div></div>
<div class="ttc" id="classcaffe_1_1Blob_html"><div class="ttname"><a href="classcaffe_1_1Blob.html">caffe::Blob</a></div><div class="ttdoc">A wrapper around SyncedMemory holders serving as the basic computational unit through which Layers...</div><div class="ttdef"><b>Definition:</b> blob.hpp:24</div></div>
<div class="ttc" id="classcaffe_1_1BaseConvolutionLayer_html_a91f929109b5c05ba6086d4c2a741ad4a"><div class="ttname"><a href="classcaffe_1_1BaseConvolutionLayer.html#a91f929109b5c05ba6086d4c2a741ad4a">caffe::BaseConvolutionLayer::dilation_</a></div><div class="ttdeci">Blob&lt; int &gt; dilation_</div><div class="ttdoc">The spatial dimensions of the dilation. </div><div class="ttdef"><b>Definition:</b> base_conv_layer.hpp:72</div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Thu Aug 3 2017 23:11:19 for Caffe by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.13
</small></address>
</body>
</html>
